package com.ss.android.video.b;

import com.bytedance.article.common.c.VideoLogManager;
import com.bytedance.common.utility.Logger;
import com.ss.android.common.AbsApiThread;
import com.ss.android.common.applog.AppLog;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.Iterator;

public final class VideoPlay extends AbsApiThread {
    private JSONArray a;

    public VideoPlay(JSONArray arg1) {

        this.a = arg1;
    }

    public final void run() {
        StringBuffer v0_3;
        StringBuffer v2;
        JSONObject v3;
        if (this.a != null && this.a.length() > 0) {
            int v1;
            for (v1 = 0; v1 < this.a.length(); ++v1) {
                try {
                    v3 = this.a.getJSONObject(v1);
                    if (v3 == null) {
                    } else {
                        Iterator v4 = v3.keys();
                        v2 = new StringBuffer();
                        try {
                            while (v4.hasNext()) {
                                Object v0_2 = v4.next();
                                if (v0_2 == null) {
                                    continue;
                                }

                                v2.append(((String) v0_2)).append(':').append(String.valueOf(v3.get(((String) v0_2)))).append("\n");
                            }
                            v0_3 = v2;
                        } catch (Exception v0_1) {
                            v0_3 = null;
                        }

                        if (v0_3 == null) {
                        } else {
                            Logger.d("VideoPlay", "video statistics: \n" + v0_3.toString());
                        }
                    }
                } catch (Throwable v0) {
                    continue;
                }


                try {
                    if (v3 == null) {
                        continue;
                    }
                    AppLog.a("video_playq", v3);
                    JSONObject v0_4 = new JSONObject();
                    try {
                        v0_4.put("statistics", v3);
                        v0_4.put("isnew", "1");
                        JSONArray v2_1 = VideoLogManager.c();
                        if (v2_1 != null) {
                            v0_4.put("vtrace", v2_1);
                        }

                        VideoLogManager.getInstance().a(v0_4);
                    } catch (JSONException v0_5) {
                    }
                } catch (Throwable v0) {
                }
            }
        }
    }
}

